package org.dna.mybatis.criteria;

/**
 * Factory methods to instantiate various Criterion implementations like 
 * LogicalExpression, SetExpression, RangeExpression, LikeExpression, 
 * SimpleExpression.
 *
 * @author andrea
 */
public class Restrictions {
    public static LogicExpression and(Criterion lhp, Criterion rhp) {
    	return new LogicExpression(lhp, LogicExpression.Operator.AND, rhp);
    }

    public static LogicExpression or(Criterion lhp, Criterion rhp) {
    	return new LogicExpression(lhp, LogicExpression.Operator.OR, rhp);
    }

    public static <T> SimpleExpression lessThan(String propertyName, T value) {
        return new SimpleExpression<T>(propertyName, SimpleExpression.Operator.LT, value);
    }
    
    public static <T> SimpleExpression eq(String propertyName, T value) {
        return new SimpleExpression<T>(propertyName, SimpleExpression.Operator.EQ, value);
    }
    
    public static LikeExpression like(String propertyName, String value) {
        return new LikeExpression(propertyName, value);
    }
}
